<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<jsp:include page="../../include/top.jsp"/>
<div class="main_body">
    <div class="span9 page_message">
        <section id="contents">
            <ul class="tab-nav nav">
                <li class="current"><a href="">修改密码<span class="arrow fa fa-sort-up"></span></a></li>
            </ul>
            <div class="tab-content">
                <div id="tab1" class="tab-pane in tab1">
                    <!-- 表单 -->
                    <form class="form-horizontal" id="myForm" name="myForm" action="${BasePath}/base/user/updatePass" method="post">
                        <input type="hidden" name="id" value="${user.id }"/>

                        <div class="form-item cf toggle-password">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                旧密码：
                                <span class="check-tips"></span>
                            </label>

                            <div class="controls">
                                <input class="input-xlarge focused" id="oldPass" name="oldPass" type="password">
                            </div>
                        </div>
                        <div class="form-item cf toggle-password">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                新密码：
                                <span class="check-tips"></span>
                            </label>

                            <div class="controls">
                                <input class="input-xlarge focused" id="password" name="password" type="password">
                            </div>
                        </div>
                        <div class="form-item cf">
                            <button class="btn submit-btn" id="submit" type="button" onclick="submitForm()" >确 定
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </section>
    </div>
</div>
<script type="text/javascript">
    function submitForm() {
        var oldPass = $("#oldPass").val();
        if (oldPass.trim() == "") {
            layer.msg('旧密码不能为空!', {icon: 5});
            return false;
        }
        var newPass = $("#password").val();
        if (newPass.trim() == "") {
            layer.msg('新密码不能为空!', {icon: 5});
            return false;
        } else if (newPass.trim().length < 6) {
            layer.msg('密码长度不能少于6位!', {icon: 5});
            return false;
        }
        $('#myForm').ajaxSubmit(function (data) {
            if (data.errno == 1) {
                layer.msg(data.errdesc,{icon: 5});
            } else {
                layer.msg('操作成功！');
                window.location.href = "${BasePath }/logout";
            }
        });
    }
</script>
<jsp:include page="../../include/bottom.jsp"/>
